package com.jt;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.jupiter.api.Test;

import java.util.Objects;

/**
 * @author dc
 * @Classname test
 * @Date 2020/2/22 10:54
 */
public class test {
    private static Log log = LogFactory.getLog(test.class);


    @Test
    public void testEquals(){
        User u1= new User(1,"张三");
        User u2= new User(1,"张三");
        log.info(123);
        System.out.println(u1.equals(u2));

    }
}
class User{
    Integer id;
    String name;

    public User(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof User)) return false;
        User user = (User) o;
        return id.equals(user.id) &&
                name.equals(user.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }
}
